//
//  UIBarButtonItem+SYExtension.m
//  siyanone
//
//  Created by LK-IOS on 2018/3/20.
//  Copyright © 2018年 LK-News. All rights reserved.
//

#import "UIBarButtonItem+SYExtension.h"

@implementation UIBarButtonItem (SYExtension)


+(UIBarButtonItem *)imageWithNormalImage:(UIImage *)norImage hightImage:(UIImage *)higImage addTarget:(id)target action:(SEL)action
{
    //右边
    SYNoHeightedButton *btn = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
    //正常状态图片
    [btn setImage:norImage forState:UIControlStateNormal];
    //高亮状态图片
    [btn setImage:higImage forState:UIControlStateHighlighted];
    //自适应尺寸
    [btn sizeToFit];
    //    [btn setBackgroundColor:[UIColor blueColor]];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    //解决按钮点击范围过大问题
    UIView *uiview = [[UIView alloc] initWithFrame:btn.frame];
    [uiview addSubview:btn];
    //创建UIBarButtonItem这个类
    return [[UIBarButtonItem alloc] initWithCustomView:uiview];
}

+(UIBarButtonItem *)imageWithNormalImage:(UIImage *)norImage selectedImage:(UIImage *)selImage addTarget:(id)target action:(SEL)action
{
    //右边
    SYNoHeightedButton *btn = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
    //正常状态图片
    [btn setImage:norImage forState:UIControlStateNormal];
    //高亮状态图片
    [btn setImage:selImage forState:UIControlStateSelected];
    //自适应尺寸
    [btn sizeToFit];
    //    [btn setBackgroundColor:[UIColor blueColor]];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    //解决按钮点击范围过大问题
    UIView *uiview = [[UIView alloc] initWithFrame:btn.frame];
    [uiview addSubview:btn];
    
    //创建UIBarButtonItem这个类
    return [[UIBarButtonItem alloc] initWithCustomView:uiview];
}




@end
